<template>
  <div>
    <!-- 抽奖组件调用 -->
    <LuckyDraw :list="list" @getResult="getResult()"/>
  </div>
</template>
<script>
// 引入LuckyDraw组件
import LuckyDraw from "../components/LuckyDraw.vue";
export default {
  name: "list",
  components: {
    LuckyDraw,
  },
  data() {
    return {
      list:[  //传参，奖品信息
            {src:require('../assets/img/1.jpg'),title:'免佣券50元'},
            {src:require('../assets/img/2.jpg'),title:'免佣券10元'},
            {src:require('../assets/img/3.jpg'),title:'免佣券30元'},
            {src:require('../assets/img/4.jpg'),title:'平衡车'},
            {src:require('../assets/img/5.jpg'),title:'免佣券15元'},
            ],
      result:[],//抽奖结果数组
    };
  },
  mounted(){
  },
  methods:{
    getResult(){  //获取结果数组
      const rand=this.list.length //生成1-奖品个数随机数
      let num1 = parseInt(Math.random()*rand,10)+1;
      let num2 = parseInt(Math.random()*rand,10)+1;
      let num3 = parseInt(Math.random()*rand,10)+1;
      let arr=[];
      arr.push(num1);
      arr.push(num2);
      arr.push(num3);
      this.result=arr
      console.log('result00',this.result)
    },
  },    
};
</script>
<style lang="less" scoped>

</style>